#############################################################################
# this is based on 7-zip													#
# you must install 7-zip before to use it and add to path variable			#
# enjoy ........... :)														#
# licface@yahoo.com															#
#############################################################################
logo = """
	__      __    ____   ______   _____   ____   _____ 
	| |     | |  / ___|  | ___|  /  _  \ / ___| |  ___|
	| |     | |  | |     | |__   | |_| | | |    | |___
	| |     | |  | |     |  __|  | | | | | |    |  ___|
	| |___	| |  | |__   | |     | | | | | |__  | |___  ___ __  _  ___
	|_____|	|_|   \___|  |_|     |_| |_|  \___| |_____|  |  |= |-| |||
"""

print logo

import os
import sys
import winsound
import time

data_name = os.path.split(sys.argv[0])
filename = data_name[1]
result_cek = ["Sub items Errors", "Everything is Ok"]
rst_cek = "Wrong password"
rst_cek2 = "Sub items Errors"
rst_cek3 =  "Everything is Ok"

usage = "\t\tUsage : " + filename + " rar_file  wordlist[*.*] \n\n" + "\t\t#################################################################\n" + "\t\t#\t\t\t\t\t\t\t\t#\n" + "\t\t#       This Only For Archieve With Containt A Password !       #\n" + "\t\t#\t\t\t\t\t\t\t\t#\n" +"\t\t#     Please make sure youre Archieve Containt A Password !     #\n" + "\t\t#\t\t\t\t\t\t\t\t#\n" + "\t\t#################################################################\n"

try:
	if (sys.argv[1] == "help"):
		os.system("cls")
		print "\n"
		print usage
	elif (sys.argv[1] == "--help"):
		os.system("cls")
		print "\n"
		print usage
	elif (sys.argv[1] == "-?"):
		os.system("cls")
		print "\n"
		print usage
	elif (sys.argv[1] == "-h"):
		os.system("cls")
		print "\n"
		print usage
	else:	
		dataQ = open(sys.argv[2])
		data = dataQ.readlines()
		len_data = len(data)
		dataQ.seek(len_data)
		
		for x in range(1, len(data)):		
			dataz = str(data[-x]).split("\n")
			if (dataz[0] != ''):
				dataxxx = str(dataz[0])
			else:
				pass
		os.system("cls")
		print "\n"
		print "\t File Rar   : " + sys.argv[1] + "\n"
		print "\t Wordlist   : " + sys.argv[2] + "\n\n"
	
		for i in range(0, len(data)):
			data01 = data[i].split("\n")
			dataQ.seek(i)
			if (data01[0] != ''):
				try:
					data_file = r"\"" + sys.argv[1] + "\""
					cek_rar = os.popen("7z t \"" + sys.argv[1] + "\" -p\"" + str(data01[0]) + "\"").readlines()
					
					if (rst_cek in cek_rar[-5]):
						print "\t\t Cek For Password : \"" + str(data01[0]) + "\" is FALSE"
					elif (rst_cek in cek_rar[-4]):
						print "\t\t Cek For Password : \"" + str(data01[0]) + "\" is FALSE"
					elif (rst_cek in cek_rar[-2]):
						print "\t\t Cek For Password : \"" + str(data01[0]) + "\" is FALSE"
					elif (rst_cek2 in cek_rar[-2]):
						print "\t\t Cek For Password : \"" + str(data01[0]) + "\" is FALSE"
					else:
						if False:
							print "\n"
							print "\t\tSorry, PASSWORD NOT FOUND ! \n\n"
							dNotsound = r"d:\SOUND\Pass Not  Found.wav"
							winsound.PlaySound(dNotsound, winsound.SND_ALIAS)
							sys.exit()
						else:
							print "\n\n"
							print "\t\t PASSWORD FOUND ! \n"
							print "\t\t Cek For Password : \"" + str(data01[0]) + "\" is True"
							dNotsound = r"d:\SOUND\Pass Found.wav"
							winsound.PlaySound(dNotsound, winsound.SND_ALIAS)
							engine = pyttsx.init()
							rate = engine.getProperty('rate')
							engine.setProperty('rate', rate-30)
							engine.say("The password is " + str(data01[0]))
							engine.runAndWait()
							print "\n"
							print "\t\t Password file " + sys.argv[1] + ": \"" + str(data01[0]) + "\""
							print "\n"
							
							if (rst_cek2 in cek_rar[-2]):
								print "\n\n"
								print "\t\t PASSWORD FOUND ! OR but, CONTAINT ERROR ? \n"
								print "\t\t Cek For Password : \"" + str(data01[0]) + "\" is True"
								print "\n"
								
							else:
								print "\t\t----- py7cracker V2 -----\n"
								print "\t\t---- Sript By BL4CK1D ----"
								time.sleep(2)
								sys.exit()
						
				except IndexError, e:
					os.system("cls")
					print "\n"
					print usage
			
			else:
				pass
			
			if (dataQ.tell() == len_data - 1):	
				print "\n\n"
				print "\t\tSorry, PASSWORD NOT FOUND ! \n\n"
				#dNotsound = r"d:\SOUND\Pass Not  Found.wav"
				#winsound.PlaySound(dNotsound, winsound.SND_ALIAS)
				print "\t\t----- py7cracker V2 -----\n"
				print "\t\t---- Sript By BL4CK1D ----"
				sys.exit()
			else:
				pass

		if False:
			print "\n"
			print "\t\t----- py7cracker V2 -----\n"
			print "\t\t---- Sript By BL4CK1D ----"
		else:
			None
	
except IndexError, e:

	print "\n"
	print "\t\tPlease fill for correct Option !!!!! \n"
	print usage

except KeyboardInterrupt, q:
	os.system("cls")
	print "\n"
	print "\t\t You Cancel Operation !!!\n"
	print "\n"
	print "\t\t----- py7cracker V2 -----\n"
	print "\t\t---- Sript By BL4CK1D ----"




